<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="contact.domain.DAOContactGroup"%>
<%@page import="contact.domain.ContactGroup"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@page import="org.springframework.context.ApplicationContext" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" media="screen" href="style.css">
<title>Manage Group</title>
</head>
<body>
<jsp:include page="menu.html" />
<jsp:include page="menuGroup.html" />
<div id="content">
<form id="manageGroup">
<%
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
DAOContactGroup daoGroup = (DAOContactGroup) context.getBean("DAOContactGroup");
List groups = daoGroup.readAll();
%>
<h1>Groups</h1>
<table>
	<tr>
		<th>Name</th>
		<th></th>
	</tr>
	<%
	Iterator iter = groups.iterator();
	while (iter.hasNext()) {
		ContactGroup group = (ContactGroup) iter.next();
		out.println("<tr>"
				+ "<td>" + group.getGroupName() + "</td>"
				+ "<td><a class='submit details' href=\"showgroup.jsp?idGroup="+group.getGroupId()+"\">Details</a></td>"
				+ "</tr>");
	}
	%>
</table>
<h2><%= groups.size()%> group(s)</h2>
</form>
</div>
</body>
</html>